package com.enation.app.javashop.api.client;

import com.enation.app.javashop.model.base.SceneType;
import com.enation.app.javashop.model.base.vo.SmsSendVO;
import com.enation.app.javashop.service.base.service.SmsManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

/**
 * @author fk
 * @version v2.0
 * @Description:
 * @date 2018/8/15 10:50
 * @since v7.0.0
 */
@RestController
@RequestMapping("/client/sms")
@ApiIgnore
public class SmsClientController {

    @Autowired
    private SmsManager smsManager;


    @GetMapping("/valid")
    public boolean valid(@RequestParam("scene")String scene, @RequestParam("mobile")String mobile, @RequestParam("code")String code) {
        return smsManager.valid(scene, mobile, code);
    }

    @PostMapping("/send-message")
    public void sendSmsMessage(@RequestParam("by_name")String byName,@RequestParam("tel") String tel, @RequestParam("scene_type") SceneType sceneType) {
        this.smsManager.sendSmsMessage(byName, tel, sceneType);
    }

    @PostMapping("/send")
    public void send(@RequestBody SmsSendVO smsSendVO) {
        smsManager.send(smsSendVO);
    }

    @RequestMapping(value = "/valid-mobile",method = RequestMethod.POST)
    public String validMobile(@RequestParam("scene")String scene, @RequestParam("mobile")String mobile){
        return smsManager.validMobile(scene,mobile);
    }


}
